package myapp;
import java.util.ArrayList;


import java.util.HashMap;
import java.util.Map;
import java.util.Set;


import android.app.Activity;
import android.app.Application;

import com.bumptech.glide.request.target.ViewTarget;
import com.bigchun.seeland.R;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
//import com.hyphenate.chat.ChatClient;
//import com.hyphenate.helpdesk.easeui.UIProvider;


public class MyApp extends Application {
    public String comname = "";
    public String AppId = "17352770";
    public String AppKey = "Y823IGKOS0yo6dK2QSQiTHci";
    public String AppSecret = "lK90kmpvITGSoSwDW0ifZpPRwZIavPVg";


    @Override
    public void onCreate() {
        super.onCreate();
        this.setTheme(android.R.style.Theme_DeviceDefault_Light_NoActionBar_Fullscreen);
        ViewTarget.setTagId(R.id.glide_tag);
        // 以下是原先的代码实现，保持不变
        if (activityList == null) {

            activityList = new ArrayList<Activity>();
        }

//        ChatClient.Options options = new ChatClient.Options();
//        options.setAppkey("1493191014068972#kefuchannelapp75159");//必填项，appkey获取地址：kefu.easemob.com，“管理员模式 > 渠道管理 > 手机APP”页面的关联的“AppKey”
//        options.setTenantId("75159");//必填项，tenantId获取地址：kefu.easemob.com，“管理员模式 > 设置 > 企业信息”页面的“租户ID”

//        // Kefu SDK 初始化
//        if (!ChatClient.getInstance().init(this, options)){
//            return;
//        }
//        // Kefu EaseUI的初始化
//        UIProvider.getInstance().init(this);
//        //后面可以设置其他属性



        FacebookSdk.sdkInitialize(getApplicationContext());
        AppEventsLogger.activateApp(this);


    }
    private ArrayList<Activity> activityList = null;

    public ArrayList<Activity> getActivity() {
        return activityList;
    }


//    public static String siteurl ="https://mywood-back.bigchun.com";//测试
    public static String siteurl ="https://www.seeland-wood.com";//正式
    //    public static String siteurl ="http://seeland.woodwoodslab.com";
    public static String Codeversion = "9_1";//演示站版本号



    private String integralrulurl = siteurl + "/index.php?ctrl=app&action=single&code=jfgz";
    public static String RequestVersion = "android gh/8_9 neriamiaw";

    public static String ImgUrl(String img){
        try {
            if (!img.equals(null) && !img.equals("") && img.length() > 5 ){
                if (img.indexOf("http") == -1) {
                    if(img.indexOf("/") != 0) {
                        img = siteurl + img;
                    }else{
                        img = siteurl +'/'+ img;
                    }
                }
            }
        }catch (Exception e){
            img="";
        }
        return img;
    }
    public String getVersion() {
        return Codeversion;
    }

    public String getWebConfig() {
        return siteurl;
    }



    /**
     * 添加到销毁队列
     *
     * @param activity 要销毁的activity
     */
    public static void addDestoryActivity(Activity activity,String activityName) {
        destoryMap.put(activityName,activity);
    }

    private static Map<String,Activity> destoryMap = new HashMap<>();
    public static void destoryActivity(String activityName) {
        Set<String> keySet=destoryMap.keySet();
        for (String key:keySet){
            destoryMap.get(key).finish();
        }
    }
}
